'use strict'

import { app } from 'electron'
import initWindow from './electron/library/windowManager'
import ipcMain from './electron/library/ipcMain'
import DisableButton from './electron/config/DisableButton'
// 初始化

const Store = require('electron-store');
// 初始化
Store.initRenderer();
// 初始化-ipcMain
ipcMain.Mainfunc()

// 解决Electron Security Warning (Node.js Integration with Remote Content) This renderer process has Nod
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
// 解决9.x跨域异常问题
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')

function onAppReady () {
  console.log('33333333333333333333')
  initWindow()
  DisableButton.Disablef12()
}
function onAppReady22 () {
  console.log('2222222222222222222')
  initWindow()
  DisableButton.Disablef12()
}

app.isReady() ? onAppReady22() : app.on('ready', onAppReady)

app.on('window-all-closed', () => {
  // 所有平台均为所有窗口关闭就退出软件
  console.log('window-all-closed')
  app.quit()
})
app.on('browser-window-created', () => {
  console.log('window-created')
})

if (process.defaultApp) {
  if (process.argv.length >= 2) {
    app.removeAsDefaultProtocolClient('future-electron')
    console.log('有于框架特殊性开发环境下无法使用')
  }
} else {
  app.setAsDefaultProtocolClient('future-electron')
}
